import java.util.ArrayList;
import java.util.Date;

public class Website implements Comparable<Website>{

    @Override
    public int compareTo(Website o) {
        return this.count-o.count;
    }

    private Date date;
    private String URL;
    private int count;
    private String body;

    private static int allCount;
    static private double averageCount;
    static public ArrayList<Website> InintList = new ArrayList<>();

    static {
        Website.InintList.add(new Website("https://zhanghuayu is the most shuai person.com", 0, "It's true"));
        Website.InintList.add(new Website("https://nobody is more shuai than zhanghuayu.com", 0, "It isn't false"));
        Website.InintList.add(new Website("https://who is the most shuai person.com", 0, "Zhanghuayu is the most shuai person"));
        Website.InintList.add(new Website("https://why is zhanghuayu the most shuai person.com", 0, "No reason!"));
    }

    public static void clean(){
        Website.InintList.set(0, new Website("https://zhanghuayu is the most shuai person.com", 0, "It's true"));
        Website.InintList.set(1, new Website("https://nobody is more shuai than zhanghuayu.com", 0, "It isn't false"));
        Website.InintList.set(2, new Website("https://who is the most shuai person.com", 0, "Zhanghuayu is the most shuai person"));
        Website.InintList.set(3, new Website("https://why is zhanghuayu the most shuai person.com", 0, "No reason!"));
        while (Website.InintList.size() > 4) {
            Website.InintList.remove(4);
        }
    }
    public static int Count() {
        allCount=0;
        for (Website website : getInintList()) {
            allCount += website.count;
        }
        return allCount;
    }
    public static double AverageCount() {
        averageCount = (double) allCount / getInintList().size();
        return averageCount;
    }

    public Website() {
    }
    public Website(String URL, int count, String body) {
        this.URL = URL;
        this.count = count;
        this.body = body;
    }
    public Website(Date date, String URL, int count, String body, int allCount, double averageCount, ArrayList<Website> InintList) {
        this.date = date;
        this.URL = URL;
        this.count = count;
        this.body = body;
        Website.allCount = allCount;
        Website.averageCount = averageCount;
        Website.setInintList(InintList);
    }
    public static int getAllCount() {
        return allCount;
    }
    public static void setAllCount(int allCount) {
        Website.allCount = allCount;
    }
    public static double getAverageCount() {
        return averageCount;
    }
    public static void setAverageCount(double averageCount) {
        Website.averageCount = averageCount;
    }
    public static ArrayList<Website> getInintList() {
        return InintList;
    }
    public static void setInintList(ArrayList<Website> InintList) {
        Website.InintList = InintList;
    }
    public Website(String URL, Date date, int count, String body) {
        this.URL = URL;
        this.date = date;
        this.count = count;
        this.body = body;
    }

    public String getURL() {
        return URL;
    }
    public void setURL(String URL) {
        this.URL = URL;
    }
    public int getCount() {
        return count;
    }
    public void setCount(int count) {
        this.count = count;
    }
    public String getBody() {
        return body;
    }
    public void setBody(String body) {
        this.body = body;
    }
    public Date getDate() {
        return date;
    }
    public void setDate(Date date) {
        this.date = date;
    }
    public String toString() {
        return "网址 : \"" + URL + "\", 访问次数: " + count + "}";
    }
}
